package com.zzy.demo.validate;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.springframework.beans.factory.annotation.Autowired;

import com.zzy.demo.service.UserService;

/**
 * @category Class description
 * @author heyingcheng
 * @email horay_hyc@qq.com
 * @date 2017/12/17 20:13
 */
public class MyConstratintValidator implements ConstraintValidator<MyConstraint, Object> {

	@Autowired
	private UserService userService;

	@Override
	public void initialize(MyConstraint constraintAnnotation) {
		System.out.println("----------------My validator init--------------");
	}

	@Override
	public boolean isValid(Object value, ConstraintValidatorContext context) {
		System.out.println(value + "--------------------- " + userService.testService());
		return false;
	}

}
